package com.scgl.sheet.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;


import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.scgl.sheet.domain.ScglBasic;
import com.scgl.sheet.service.IScglBasicService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 基础信息Controller
 *
 * @author ruoyi
 * @date 2024-10-30
 */
@RestController
@RequestMapping("/basic")
public class ScglBasicController extends BaseController
{
    @Autowired
    private IScglBasicService scglBasicService;

    /**
     * 查询基础信息列表
     */
    @RequiresPermissions("sheet:basic:list")
    @GetMapping("/list")
    public TableDataInfo list(ScglBasic scglBasic)
    {
        startPage();
        List<ScglBasic> list = scglBasicService.selectScglBasicList(scglBasic);
        return getDataTable(list);
    }

    /**
     * 导出基础信息列表
     */
    @RequiresPermissions("sheet:basic:export")
    @PostMapping("/export")
    public void export(HttpServletResponse response, ScglBasic scglBasic)
    {
        List<ScglBasic> list = scglBasicService.selectScglBasicList(scglBasic);
        ExcelUtil<ScglBasic> util = new ExcelUtil<ScglBasic>(ScglBasic.class);
        util.exportExcel(response, list, "基础信息数据");
    }

    /**
     * 获取基础信息详细信息
     */
    @RequiresPermissions("sheet:basic:query")
    @GetMapping(value = "/{worko}")
    public AjaxResult getInfo(@PathVariable("worko") String worko)
    {
        return success(scglBasicService.selectScglBasicByWorko(worko));
    }

    /**
     * 新增基础信息
     */
    @RequiresPermissions("sheet:basic:add")
    @Log(title = "基础信息新增", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ScglBasic scglBasic)
    {
        return toAjax(scglBasicService.insertScglBasic(scglBasic));
    }

    /**
     * 修改基础信息
     */
    @RequiresPermissions("sheet:basic:edit")
    @Log(title = "基础信息修改", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ScglBasic scglBasic)
    {
        return toAjax(scglBasicService.updateScglBasic(scglBasic));
    }

    /**
     * 删除基础信息
     */
    @RequiresPermissions("sheet:basic:remove")
     @Log(title = "基础信息删除", businessType = BusinessType.DELETE)
	@DeleteMapping("/{workos}")
    public AjaxResult remove(@PathVariable String[] workos)
    {
        return toAjax(scglBasicService.deleteScglBasicByWorkos(workos));
    }
}
